home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / intuition / reqtools_2.1e / rexxreqtools / demo.rexx next >
OS/2 REXX Batch file  |  1994-11-17  |  10KB  |  255 lines

  1. /*$VER: Demo.rexx 37.18 (6.6.93)
  2. **
  3. **  $Filename: Demo.rexx $
  4. **  $Version: 37.18 $
  5. **  $Date: 6.6.93 $
  6. **  $Creation: 2.1.93 $
  7. **
  8. **  Demo ARexx script for rexxreqtools.library
  9. **
  10. **  (C) Copyright 1993 Rafael D'Halleweyn
  11. */
  12.  
  13. /* NOTE: A Comma at the end of a line is no argument seperator but contituation
  14.  *       character for a statement that continues on the next line!!
  15.  */
  16.  
  17. NL = '0a'x
  18.  
  19. call addlib("rexxreqtools.library", 0, -30, 0)
  20.  
  21. call rtezrequest( "RexxReqTools 1.3 Demo" || NL ||,
  22.                   "~~~~~~~~~~~~~~~~~~~~~" || NL ||,
  23.                   "'rexxreqtools.library' offers several" || NL ||,
  24.                   "different types of requesters:", "Let's see them")
  25.  
  26.  
  27. call rtezrequest( "But first you'll have to pick the font" || NL ||, 
  28.                   "that you want to use for this demo.")
  29. call rtfontrequest("Pick font", , 'rtfo_flags=freqf_fixedwidth', font)
  30. if font then
  31.   fonttag = "rt_font=" || font.name || "/" || font.height
  32. else
  33.   fonttag = ""
  34.  
  35.  
  36. /* STRING REQUESTER */
  37.  
  38. call rtezrequest( "NUMBER 1:" || NL ||,
  39.                   "String requester" || NL ||,
  40.                   "function: rtgetstring()", "Show me" , , fonttag)
  41.  
  42. buffer = rtgetstring("A bit of text", , "Enter anything:", , fonttag)
  43. if buffer == "" then
  44.   call rtezrequest("You entered nothing!", "I'm sorry", , fonttag)
  45. else
  46.   call rtezrequest( "You entered this string:" || NL ||,
  47.                     "'" || buffer || "'.", "So I did", , fonttag)
  48.  
  49. call rtgetstring( , "These are two new features of ReqTools 2.0:" || NL ||,
  50.                     "Text above the entry gadget and more than" || NL ||,
  51.                     "one response gadget.", "Enter anything:",,
  52.   " _Ok |New _2.0 feature!|_Cancel", fonttag)
  53. if rtresult == 2 then call rtezrequest( "Yep, this is a new" || NL ||,
  54.                                         "ReqTools 2.0 feature!", "Oh boy!",,
  55.                                        , fonttag)
  56.  
  57. call rtgetstring(buffer, "New is also the ability to switch off" || NL ||,
  58.                          "the backfill pattern. You can also center" || NL ||,
  59.                          "the text above the entry gadget." || NL ||,
  60.                          "These new features are also available" || NL ||,
  61.                          "in the rtgetlong() requester.",,
  62.   "Enter anything:"," _Ok |_Abort|_Cancel",,
  63.   fonttag,
  64.   "rtgs_backfill = false rtgs_flags = gsreqf_centertext|gsreqf_highlighttext")
  65. if rtresult == 2 then
  66.   call rtezrequest( "What!! You pressed abort!?!" || NL ||,
  67.                     "You must be joking :-)", "Ok, continue", , fonttag)
  68.  
  69.  
  70. /* NUMBER REQUESTER */
  71.  
  72. call rtezrequest( "NUMBER 2:" || NL ||,
  73.                   "Number requester" || NL ||,
  74.                   "function: rtgetlong()", "Show me", , fonttag)
  75.  
  76. long = rtgetlong(, , "Enter a number:", , fonttag,
  77.                                           "rtgl_min = -666 rtgl_max = 666")
  78. if rtresult == 0 then
  79.   call rtezrequest("You entered nothing!", "I'm sorry", , fonttag)
  80. else
  81.   do
  82.     text =         "The number you entered was:" || NL
  83.     text = text || long
  84.     if long == 666 then text = text "(you devil!)"
  85.     if long == -666 then text = text "(you negative devil!)"
  86.     call rtezrequest(text, "So it was", , fonttag)
  87.   end
  88.  
  89.  
  90. /* MESSAGE REQUESTER */
  91.  
  92. call rtezrequest( "NUMBER 3:" || NL ||,
  93.                   "Message requester, the requester" || NL ||,
  94.                   "you've been using all the time!" || NL ||,
  95.                   "function: rtezrequest()", "Show me more", , fonttag)
  96.  
  97. call rtezrequest( "Simplest usage: some body text" || NL ||,
  98.                   "and a single centered gadget.", "Got it", , fonttag)
  99.  
  100. do while rtezrequest( "You can also use two gadgets" || NL ||,
  101.                       "to ask the user something." || NL ||,
  102.                       "Do you understand?", "Of course|Not really", , fonttag) == 0
  103.   call rtezrequest("You are not one of the brightest are you?",,
  104.         "Let me try again", , fonttag)
  105. end
  106.  
  107. call rtezrequest("Great, we'll continue then.", "Fine", , fonttag)
  108.  
  109. call rtezrequest( "You can also put up a requester" || NL ||,
  110.                   "with three choices:" || NL ||,
  111.                   "How do you like the demo so far ?",,
  112.                   "_Great|_So so|_Rubbish", , fonttag)
  113. if rtresult == 0 then
  114.   call rtezrequest( "Too bad, we really hoped" || NL ||,
  115.                     "you would like it better.", "So what", , fonttag)
  116. if rtresult == 1 then
  117.   call rtezrequest("We're glad you like it so much.", "Fine", , fonttag)
  118. if rtresult == 2 then
  119.   call rtezrequest( "Maybe if you run the demo" || NL ||,
  120.                     "again you'll REALLY like it!", "Perhaps", , fonttag)
  121.  
  122. call rtezrequest( "The number of responses is not limited to" || NL ||,
  123.                   "three as you can see. The gadgets are labeled" || NL ||,
  124.                   "with the return code from rtezrequest()." || NL ||,
  125.                   "Pressing Return will choose 4, note that" || NL ||,
  126.                   "4's button text is printed in boldface.",,
  127.   "1|2|3|4|5|0", , fonttag "rtez_defaultresponse = 4")
  128.  
  129. call rtezrequest("You picked '" || rtresult || "'.", "How true", , fonttag)
  130.  
  131. if rtezrequest( "It is also possible to pass extra IDCMP flags" || NL ||,
  132.                 "that will satisfy rtezrequest(). This requester" || NL ||,
  133.                 "has had 'idcmp_diskinserted' passed to it." || NL ||,
  134.                 "(Try inserting a disk).", "Continue", ,,
  135.     fonttag "rt_idcmpflags = idcmp_diskinserted") == 0 then
  136.   call rtezrequest("You used the 'Continue' gadget.", "I did", , fonttag)
  137. else
  138.   call rtezrequest("You inserted a disk.", "I did", , fonttag)
  139.  
  140. call rtezrequest( "Finally, it is possible to specify the position of the" || NL ||,
  141.                   "requester." || NL ||,
  142.                   "E.g. at the top left of the screen, like this." || NL ||,
  143.                   "This works for all requesters, not just rtezrequest()!",,
  144.   "Amazing", , fonttag "rt_reqpos = reqpos_topleftscr")
  145.  
  146. call rtezrequest( "Alternatively, you can center" || NL ||,
  147.                   "the requester on the screen." || NL ||,
  148.                   "Check out 'rexxreqtools.doc'" || NL ||,
  149.                   "or 'rexxreqtools.guide' for" || NL ||,
  150.                   "all the possibilities.", "I'll do that", ,,
  151.   fonttag "rt_reqpos = reqpos_centerscr")
  152.  
  153.  
  154. /* FILE REQUESTER */
  155.  
  156. call rtezrequest( "NUMBER 4:" || NL ||,
  157.                   "File requester" || NL ||,
  158.                   "function: rtfilerequest()", "Demonstrate", , fonttag)
  159.  
  160. filename = rtfilerequest(, , "Pick a file" , , fonttag "rtfi_buffer = true")
  161. if rtresult == 0 then
  162.   call rtezrequest("You didn't pick a file.", "No", , fonttag)
  163. else
  164.   call rtezrequest("You picked the file:" || NL || filename, "Right", , fonttag)
  165.  
  166. call rtezrequest( "The file requester has the ability" || NL ||,
  167.                   "to allow you to pick more than one" || NL ||,
  168.                   "file (use Shift to extend-select)." || NL ||,
  169.                   "Note the extra gadgets you get.", "Interesting", , fonttag)
  170.  
  171. filename = rtfilerequest(, , "Pick some files", ,,
  172.             fonttag "rtfi_flags = freqf_multiselect")
  173. if rtresult == 1 then
  174.   call rtezrequest( "You selected" rtresult.count "files, " || NL ||,
  175.                     "this is the first one:" || NL ||,
  176.                     rtresult.1, "Aha", , fonttag)
  177.  
  178. call rtezrequest( "The file requester can be used" || NL ||,
  179.                   "as a directory requester as well.", "Let's see that", ,,
  180.                    fonttag)
  181.  
  182. dirname = rtfilerequest(, , "Pick a directory", ,,
  183.             fonttag "rtfi_flags = freqf_nofiles")
  184. if rtresult == 0 then
  185.   call rtezrequest("You didn't pick a directory.", "No", , fonttag)
  186. else
  187.   call rtezrequest("You picked the directory:" || NL || dirname, "Right", ,,
  188.         fonttag)
  189.  
  190.  
  191. /* FONT REQUESTER */
  192.  
  193. call rtezrequest( "NUMBER 5:" || NL ||,
  194.                   "Font requester" || NL ||,
  195.                   "function: rtfontrequest()", "Show", , fonttag)
  196.  
  197. call rtfontrequest("Pick a font", , fonttag "rtfo_flags = freqf_style")
  198. if rtresult == 0 then
  199.   call rtezrequest("You canceled." || NL || "Was there no font you liked ?",,
  200.          "Nope", , fonttag)
  201. else
  202.   call rtezrequest( "You picked the font:" || NL ||,
  203.                     rtresult.name "s